package com.cardbaobao.cardbabyclient.expand.transformer;

import android.support.v4.view.ViewPager;
import android.view.View;

/**
 * Created by Jiangzx on 8:58.
 */

public class ScaleTransformer implements ViewPager.PageTransformer {
    private float mMinScale=0.8f;

    public ScaleTransformer(float scale){
        this.mMinScale=scale;
    }

    @Override
    public void transformPage(View page, float position) {
            if(position<-1){
                configMini(page);
            }else if(position<=1){
                float scale=Math.max(mMinScale,1 - Math.abs(position));
                page.setScaleY(scale);
            }else{
                configMini(page);
            }
    }

    private void configMini(View view){
        view.setScaleY(mMinScale);
    }
}
